#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void cha_xu(int arr[], int n, int num)
{
	int i = 0;
	arr[n] = num;
	for (i = 0; i < n; i++)
	{
		if (arr[i] > num)
		{
			int j = 0;
			for (j = n; j > i; j--)
			{
				arr[j] = arr[j - 1];
			}
			arr[i] = num;
			break;
		}
	}
}

int main()
{
	int n = 0;
	int n1 = 0;
	scanf("%d%d", &n, &n1);
	int arr[1000] = { 0 };
	int arr1[1000] = { 0 };
	int i = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
	}
	for (i = 0; i < n1; i++)
	{
		scanf("%d", &arr1[i]);
	}

	for (i = 0; i < n1; i++)
	{
		cha_xu(arr, n, arr1[i]);
		n++;
	}

	
	for (i = 0; i < n ; i++)
		printf("%d ", arr[i]);

	return 0;
}